package mrdemo010;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class SortWithNameMap  extends Mapper<LongWritable, Text, LongWritable, Text>{
	
	private Text val = new Text("");

	@Override
	protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, LongWritable, Text>.Context context)
			throws IOException, InterruptedException {
		
		String line = value.toString();
		
		//输入的数据行，长度大于0则输出
		if(line!=null && line.trim().length()>0) {
			String[] splited =  line.split(",");
			if(splited!=null && splited.length == 3 ) {
				val.set(splited[0] + "," +  splited[1]);
				context.write(new LongWritable(Long.parseLong(splited[2])), val );
			}
 		}
	}
}
